package com.yonyou.pmclouds.alterandvisacategory.process;

import com.yonyou.pmclouds.alterandvisacategory.entity.AlterAndVisaCategoryVO;
import com.yonyou.pmclouds.alterandvisacategory.mapper.AlterAndVisaCategoryMapper;
import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import org.apache.commons.lang3.StringUtils;

public class AlterAndVisaCategoryInsertCheckProcessor implements SingleProcessor<AlterAndVisaCategoryVO>{

    private AlterAndVisaCategoryMapper mapper;

    public AlterAndVisaCategoryInsertCheckProcessor(AlterAndVisaCategoryMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public void process(AlterAndVisaCategoryVO vo, AlterAndVisaCategoryVO orig) throws BusinessException {
        if(vo == null){
            throw new BusinessException("签证类别为空！");
        }else{
            if(mapper.countName(vo.getPkTenant(), vo.getSname()) > 0){
                throw new BusinessException("签证类别名称重复！");
            }
        }
    }
}
